const query = require('../../models');

module.exports = {
  list(req, res) {
    const totalSql = `select count(*) as total from activities`;

    const listSql = `select * from activities order by activity_id desc limit ?,?`;
    const currentPage = parseInt(req.query.currentPage);
    const pageSize = parseInt(req.query.pageSize);
    const start = (currentPage - 1) * pageSize;

    query(listSql, [start, pageSize])
      .then(result => {
        res.json({
          code: '200',
          errMsg: '操作成功',
          data: result
        })
      })
      .catch(err => {
        res.json({
          code: '1001',
          errorMsg: '操作失败',
          err: err
        })
      });
  },
  getById(req, res) {
    const sql = ``;

    query(sql, [])
      .then(result => {
        res.json({
          code: '200',
          errMsg: '操作成功',
          data: {}
        })
      })
      .catch(err => {
        res.json({
          code: '1001',
          errorMsg: '操作失败',
          err: err
        })
      });
  },
  delById(req, res) {
    const sql = ``;

    query(sql, [])
      .then(result => {
        res.json({
          code: '200',
          errMsg: '操作成功',
          data: {}
        })
      })
      .catch(err => {
        res.json({
          code: '1001',
          errorMsg: '操作失败',
          err: err
        })
      });
  },
  checkById(req, res) {
    const sql = ``;

    query(sql, [])
      .then(result => {
        res.json({
          code: '200',
          errMsg: '操作成功',
          data: {}
        })
      })
      .catch(err => {
        res.json({
          code: '1001',
          errorMsg: '操作失败',
          err: err
        })
      });
  },
}